package com.huifaapp.mall.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.huifaapp.mall.R;

import java.util.List;

/**
 * Created by duanyu on 2017/12/21.
 */

public class PopuplayoutSizeAdapter extends RecyclerView.Adapter<PopuplayoutSizeAdapter.SizeViewHolder>implements View.OnClickListener {
   private  List<String>sizelist;
    private  Context Context;

    public PopuplayoutSizeAdapter(List<String> sizelist, android.content.Context context) {
        this.sizelist = sizelist;
        Context = context;
    }

    @Override
    public PopuplayoutSizeAdapter.SizeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View holder = LayoutInflater.from(parent.getContext()).inflate(R.layout.itme_popuplayout_sizeadapter, parent, false);
        holder.setOnClickListener(this);
        return new SizeViewHolder(holder);
    }

    @Override
    public void onBindViewHolder(PopuplayoutSizeAdapter.SizeViewHolder holder, int position) {
          holder.sizetext.setText(sizelist.get(position));
          holder.itemView.setTag(position);
    }
    public interface MySizeItemclickListener {
        void Sizeitemclick(View view, int position);
    }
    public PopuplayoutSizeAdapter.MySizeItemclickListener mMySizeItemclickListener;

    public void setmMyItemclickListener(PopuplayoutSizeAdapter.MySizeItemclickListener mMySizeItemclickListener) {
        this.mMySizeItemclickListener = mMySizeItemclickListener;
    }
    @Override
    public int getItemCount() {
        return sizelist.size();
    }

    @Override
    public void onClick(View v) {
        if (mMySizeItemclickListener != null) {
            mMySizeItemclickListener.Sizeitemclick(v, (Integer) v.getTag());
        }
    }

    class SizeViewHolder extends RecyclerView.ViewHolder {

        private final TextView sizetext;

        public SizeViewHolder(View itemView) {
            super(itemView);
            sizetext = (TextView) itemView.findViewById(R.id.Sizetext);
        }
    }
}
